# Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
# Project developers.  See the top-level LICENSE file for dates and other
# details.  No copyright assignment is required to contribute to VisIt.

##############################################################################
#  Modifications:
#    Jeremy Meredith, Tue Jun  5 17:38:34 EDT 2007
#    Renamed the main object files to a more standard SEROBJ, PAROBJ, and FOBJ
#    to play better with automatic dependencies.
#
#    Jeremy Meredith, Fri Nov  2 18:28:33 EDT 2007
#    Put the binary in the real bin dir to play better with OS X.  Also,
#    set export-dynamic based on a configure-detected value, since not all
#    platforms support or need it.
#
##############################################################################

@SET_MAKE@
@VARIABLES@

SIMSER=$(tmpbin)/simulation
SIMPAR=$(tmpbin)/psimulation

SIMSRC=sim.c simconnection.c
SEROBJ=$(SIMSRC:.c=.o)
PAROBJ=$(SIMSRC:.c=_par.o)

SIMFSER=simf
SIMFSRC=simf.f
FSEROBJ=$(SIMFSRC:.f=.o)

CPPFLAGS=-I. @CPPFLAGS@
CFLAGS=-I. -I$(TOPDIR)/include/visit -Wimplicit-function-declaration @CFLAGS@
F77FLAGS=-I$(TOPDIR)/include/visit
LDFLAGS=@LDFLAGS@ @EXE_LDFLAGS@ -L$(TOPDIR)/archives

PARLIBS=$(MPI_LIBS)

LIBS=@LIBS@ -lpthread -lsim
FLIBS=@LIBS@ -lpthread -lsimf -lsim

EXPORT_DYNAMIC=@EXPORT_DYNAMIC@
LIBDEP=$(TOPDIR)/archives/libsim.a

BUILD_FORTRAN=$(SIMFSER)

all:  $(SIMSER) $(SIMPAR) @BUILD_FORTRAN@

$(SIMSER): $(SEROBJ) $(LIBDEP)
	$(CC) $(EXPORT_DYNAMIC) $(SEROBJ) $(LDFLAGS) $(LIBS)    -o $@

$(SIMPAR): $(PAROBJ) $(LIBDEP)
	$(CC) $(EXPORT_DYNAMIC) $(LDFLAGS) $(PAROBJ) $(LIBS) $(PARLIBS)  -o $@

$(SIMSER).pure: $(SEROBJ) $(LIBDEP)
	purify $(LD) $(LDFLAGS) $(SEROBJ) $(LIBS) -o $@

$(SIMFSER): $(FSEROBJ) $(LIBDEP)
	$(F77) $(EXPORT_DYNAMIC) $(FSEROBJ) $(LDFLAGS) $(FLIBS) -o $@

clean:
	$(RM) $(SEROBJ) $(SIMSER) $(SIMSER).pure
	$(RM) $(PAROBJ) $(SIMPAR)
	$(RM) $(FSEROBJ) $(SIMFSER)


@TARGETS@
